import requests


class TpshopApi(object):
    def get_verify_code(self, session):
        session.get(url="http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify")

    def login(self, session, req_data):
        resp = session.post(url="http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=do_login",
                            data=req_data)

        return resp



if __name__ == '__main__':
    tpshop = TpshopApi()
    session = requests.Session()
    tpshop.get_verify_code(session)
    req_body = {"username": "13012345678", "password": "123456", "verify_code": "8888"}
    resp = tpshop.login(session, req_body)
    print(resp.json())
